﻿using System;
using System.Windows.Forms;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.DB.Mechanical;
using Autodesk.Revit.UI;
using Autodesk.Revit.UI.Selection;
using YArchitech.Revit;

namespace YArchitech.Public
{
	[Transaction(TransactionMode.Manual)]
	[Regeneration(RegenerationOption.Manual)]
	public class TestDetermineTwoDuctsAlignmentCommand : HYNoTranExternalCommand
	{
		public override void FilterProcess()
		{
            base.FilterViewType.Add((ViewType)4);
            base.FilterViewType.Add((ViewType)117);
			base.FilterProcess();
		}

		public override Result HYExecute()
		{
			ISelectionFilter selectionFilter = new DuctFilter();
			Reference reference = base.Sel.PickObject((Autodesk.Revit.UI.Selection.ObjectType)1, selectionFilter, "选择第一根风管……");
			Reference reference2 = base.Sel.PickObject((Autodesk.Revit.UI.Selection.ObjectType)1, selectionFilter, "选择第二根风管……");
			Duct duct = base.Doc.GetElement(reference) as Duct;
			Duct duct2 = base.Doc.GetElement(reference2) as Duct;
			YJKPiping<Duct> hypiping = new YJKPiping<Duct>(duct);
			YJKPiping<Duct> hypiping2 = new YJKPiping<Duct>(duct2);
			DetermineTwoDuctsAlignment determineTwoDuctsAlignment = new DetermineTwoDuctsAlignment(-hypiping.GetCloseConnector(hypiping2.StartConnector.Origin, false).CoordinateSystem.BasisZ, duct, duct2);
			if (determineTwoDuctsAlignment.IsTopAlign)
			{
				MessageBox.Show("顶对齐");
			}
			if (determineTwoDuctsAlignment.IsBottomAlign)
			{
				MessageBox.Show("底对齐");
			}
			if (determineTwoDuctsAlignment.IsVerticalMiddleAlign)
			{
				MessageBox.Show("竖直中对齐");
			}
			if (determineTwoDuctsAlignment.IsLeftAlign)
			{
				MessageBox.Show("坐对齐");
			}
			if (determineTwoDuctsAlignment.IsRightAlign)
			{
				MessageBox.Show("右对齐");
			}
			if (determineTwoDuctsAlignment.IsHorizontalMiddleAlign)
			{
				MessageBox.Show("水平中对齐");
			}
			MessageBox.Show("222");
			return Autodesk.Revit.UI.Result.Succeeded;
		}
	}
}
